﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using System.Data.SqlClient;
using System.Text.RegularExpressions;

namespace Defector
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Report : Window
    {

        public int reportNumber;
        public SqlConnection con;

        public Report()
        {
            InitializeComponent();
        }

        public void Start()
        {
            con.Open();
            SqlCommand cmd = new SqlCommand("SELECT dbo.People.First_Name, dbo.People.Last_Name, dbo.Trouble_Report.Trouble_Report_Id, dbo.Trouble_Report.Date_Submitted, dbo.Trouble_Report.PersonId, dbo.Softwares.Software_Name, dbo.Trouble_Report.Priority, dbo.Trouble_Report.Status, dbo.Trouble_Report.Description, dbo.Trouble_Report.Headline, dbo.Softwares.Software_Id, dbo.People.Id, dbo.Trouble_Report.SoftwareSoftware_Id, dbo.Trouble_Report.Date_Completed FROM         dbo.Trouble_Report INNER JOIN dbo.People ON dbo.Trouble_Report.PersonId = dbo.People.Id INNER JOIN dbo.Softwares ON dbo.Trouble_Report.SoftwareSoftware_Id = dbo.Softwares.Software_Id WHERE     (dbo.Trouble_Report.Trouble_Report_Id = "+ reportNumber +")", con);
            SqlDataAdapter adapter = new SqlDataAdapter(cmd);
            DataSet reportData = new DataSet();
            adapter.Fill(reportData);
            ownerBox.Text = reportData.Tables[0].Rows[0][0].ToString() + " " + reportData.Tables[0].Rows[0][1].ToString();
            priorityBox.SelectedIndex = 4;
            softwareBox.Text = reportData.Tables[0].Rows[0][5].ToString();
            descriptionBox.Text = reportData.Tables[0].Rows[0][8].ToString();
            headlineBox.Text = reportData.Tables[0].Rows[0][9].ToString();
            con.Close();
        }
    }
}
